set(SOURCES "main.cpp"
            "app/app.cpp"
            "app/manager/mqtt_manager.cpp"
            "app/logger/logger_app.cpp"
            "app/relay_app/relay_app.cpp"
            "ota/HttpsOTA.cpp"
            "system/system_info.cpp"
            "config/settings.cpp"
            "hardware/board.cpp"
            "hardware/ws2812/ws2812.cpp"
            "hardware/PCF8574/PCF8574.cpp"
            "hardware/i2c/esp_i2c_master.cpp"

    )
set(INCLUDE_DIRS  "." 
    "app"
    "app/manager"
    "app/logger"
    "app/relay_app"
    "ota"
    "system"
    "config"
    "hardware"
    "hardware/ws2812"
    "hardware/PCF8574"
    "hardware/i2c"
    )

# 添加protocols目录及其子目录下的所有cpp文件
file(GLOB_RECURSE PROTOCOL_SOURCES "protocols/*.cpp")
list(APPEND SOURCES ${PROTOCOL_SOURCES})
# 自动发现protocols目录及其子目录下的所有头文件目录
file(GLOB_RECURSE PROTOCOL_HEADERS "protocols/*.h" "protocols/*.hpp")
foreach(header ${PROTOCOL_HEADERS})
    get_filename_component(dir ${header} DIRECTORY)
    list(APPEND INCLUDE_DIRS ${dir})
endforeach()


# 添加task目录及其子目录下的所有cpp文件
file(GLOB_RECURSE PROTOCOL_SOURCES "task/*.cpp")
list(APPEND SOURCES ${PROTOCOL_SOURCES})
# 自动发现app目录及其子目录下的所有头文件目录
file(GLOB_RECURSE PROTOCOL_HEADERS "task/*.h" "task/*.hpp")
foreach(header ${PROTOCOL_HEADERS})
    get_filename_component(dir ${header} DIRECTORY)
    list(APPEND INCLUDE_DIRS ${dir})
endforeach()

# 移除重复的包含路径
list(REMOVE_DUPLICATES INCLUDE_DIRS)

idf_component_register(
    SRCS ${SOURCES}
    INCLUDE_DIRS ${INCLUDE_DIRS}
)